MFLAGS = `Wand-config --cflags --cppflags`
MLIBS = `Wand-config --ldflags --libs`
##CFLAGS = -Wall -g
CFLAGS = 

ITPACK2D = srcv2d.f 
ITPACK2DH = itpack2d.h
ITPACK2DA = libitpack2d.a
ITLIBS = -litpack2d -lg2c
F77 = g77
CC = gcc

DIFFK = diffk
MSK = msk

now: nld2

all: t2c t2cc t2d gaussd

t2cc: src2c.f t2c.o
	f77 -o $@ src2c.f t2c.o

t2c: src2c.f t2c.f
	f77 -o $@ src2c.f t2c.f
t2d: srcv2d.f t2d.c
	f77 -o $@ srcv2d.f t2d.c

gaussd: $(DIFFK).c gaussd.c $(ITPACK2DA) $(ITPACK2DH)
	$(CC) $(MFLAGS) $(CFLAGS)  -L./ $(DIFFK).c gaussd.c $(MLIBS) $(ITLIBS) -o $@

nld%: $(DIFFK).c nld%.c $(ITPACK2DA) $(ITPACK2DH)
	$(CC) $(MFLAGS) $(CFLAGS)  -L./ $(DIFFK).c $@.c $(MLIBS) $(ITLIBS) -o $@



$(ITPACK2DA): $(ITPACK2D)
	$(F77) -o itpack2d.o -c $(ITPACK2D)
	$(AR) r $(ITPACK2DA) itpack2d.o 

gaussd-test: gaussd t3.jpg
	./gaussd t3.jpg

nld1-test: nld1 t3.jpg
	./nld1 t3.jpg

nld2-test: nld2 t3.jpg
	./nld2 t3.jpg
nld3-test: nld3 t3.jpg
	./nld3 t3.jpg

ac%: $(MSK).c ac%.c phitool.c $(ITPACK2DA) $(ITPACK2DH)
	$(CC) $(MFLAGS) $(CFLAGS)  -L./ $(MSK).c phitool.c $@.c $(MLIBS) $(ITLIBS) -o $@
acwe1-test: acwe1 t3.jpg
	./acwe1 t3.jpg
